1 using UnityEngine;
2 using
System.Collections;
3
4 [RequireComponent(
typeof(Collider))]
5 public
class OnCollideSwitchTeam : MonoBehaviour
6 {
7     
public PunTeams.Team TeamToSwitchTo;
8     
9     
public void OnTriggerEnter(Collider other)
10     {
11         
// it's ridiculously easy to switch teams. you only have to make sure you do it for your own characters
12         
// (this trigger is called on all clients, when a user's character enters the trigger...)
13
14         
// find a PhotonView and check if the character "isMine". Only then, set this client's player-team.
15         PhotonView otherPv = other.GetComponent<PhotonView>();
16         
if (otherPv != null && otherPv.isMine)
17         {
18             PhotonNetwork.player.SetTeam(
this.TeamToSwitchTo);
19         }
20     }
21 }


it's ridiculously easy to switch teams. you only have to make sure you do it for your own characters

(this trigger is called on all clients, when a user's character enters the trigger...)

find a PhotonView and check if the character "isMine". Only then, set this client's player-team.




Trò chơi Tic-Tac-Toe, game đánh caro full source code 53.485 lượt xem

Gõ tìm kiếm nhanh...